package com.kejizhentan.controller;

import com.kejizhentan.common.result.Result;
import com.kejizhentan.service.HospitalService;
import com.kejizhentan.yygh.model.hosp.Hospital;
import com.kejizhentan.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/**
 * @Author shikaifeng
 * @Date 2022/10/1 13:14
 * @Version 1.0
 */
@RestController
//@CrossOrigin
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    @GetMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }

    // 更新医院上线状态
    @ApiOperation(value = "更新医院上线状态")
    @GetMapping("/updateStatus/{id}/{status}")
    public Result lock (@PathVariable String id,
                        @PathVariable Integer status) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    // 医院详情信息
    @ApiOperation(value = "医院详情信息")
    @GetMapping("/showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id) {
        return Result.ok(hospitalService.getHospById(id));
    }

}
